package DAO;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

import Beans.PagoBean;
import HibernateUtils.HibernateUtil;

public class HibernatePagoDAO {
	private static HibernatePagoDAO instancia;
	private static SessionFactory sf;

	public static HibernatePagoDAO getInstancia(){
		if(instancia==null){
			sf=HibernateUtil.getSessionFactory();
			instancia=new HibernatePagoDAO();
		}
		return instancia;
	}
	
	

	public PagoBean buscarPago(PagoBean ab) {
		Session session=sf.openSession();
		PagoBean pago=(PagoBean) session.get(PagoBean.class,ab.getIdPago());
		session.close();
		return pago;
	}

	public List<PagoBean> getPagos(int idSucursal) {
		Session session=sf.openSession();
		List<PagoBean>pagos=session.createQuery("from PagoBean a where a.idPago=?").setInteger(0, idSucursal).list();
		return pagos;
	}
}
